package cn.linjianhui.thread;

public class BadSuspend {
    public static Object u = new Object();
    public static ChangeObjectThread t1 = new ChangeObjectThread("T1");
    public static ChangeObjectThread t2 = new ChangeObjectThread("T2");

    public static class ChangeObjectThread extends Thread {

        public ChangeObjectThread(String name) {
            super.setName(name);
        }

        public void run() {
            synchronized (u) {
                Thread.currentThread().suspend();
                System.out.println("Thread name: " + this.getName());
            }
        }
    }

    public static void main(String[] args) throws InterruptedException {
        t1.start();
        Thread.sleep(100);
        t2.start();
        t1.resume();
        Thread.sleep(100);
        t2.resume();
//        t1.join();
//        t2.join();
    }
}
